include:
  - local: .gitlab/ci/qa-common/main.gitlab-ci.yml
  - local: .gitlab/ci/qa-common/rules.gitlab-ci.yml
  - local: .gitlab/ci/qa-common/variables.gitlab-ci.yml
  - component: "gitlab.com/gitlab-org/quality/pipeline-common/allure-report@7.3.0"
    inputs:
      job_name: "e2e-test-report"
      job_stage: "report"
      aws_access_key_id_variable_name: "QA_ALLURE_AWS_ACCESS_KEY_ID"
      aws_secret_access_key_variable_name: "QA_ALLURE_AWS_SECRET_ACCESS_KEY"
      gitlab_auth_token_variable_name: "PROJECT_TOKEN_FOR_CI_SCRIPTS_API_USAGE"
      allure_results_glob: "gitlab-qa-run-*/**/allure-results"
      allure_job_name: "${QA_RUN_TYPE}"
      allure_ref_slug: "${CI_COMMIT_REF_SLUG}"

workflow:
  rules:
    - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $SCHEDULE_TYPE == "nightly"'

.ce:
  variables:
    RELEASE: ${REGISTRY_HOST}/${REGISTRY_GROUP}/build/omnibus-gitlab-mirror/gitlab-ce:${CI_COMMIT_SHA}

.ee:
  variables:
    RELEASE: ${REGISTRY_HOST}/${REGISTRY_GROUP}/build/omnibus-gitlab-mirror/gitlab-ee:${CI_COMMIT_SHA}

# ==========================================
# Prepare stage
# ==========================================
download-knapsack-report:
  extends:
    - .download-knapsack-report
    - .rules:download-knapsack

# ==========================================
# Test stage
# ==========================================

# ------------------------------------------
# Network limiting jobs
# ------------------------------------------
airgapped:
  extends:
    - .qa
    - .ee
    - .parallel
  variables:
    QA_SCENARIO: "Test::Instance::Airgapped"
    QA_RSPEC_TAGS: "--tag '~github' --tag '~external_api_calls' --tag '~skip_live_env'"

instance-image-slow-network:
  extends:
    - .qa
    - .ee
    - .parallel
  variables:
    QA_SIMULATE_SLOW_CONNECTION: "true"

# ------------------------------------------
# N+1 jobs
# ------------------------------------------
nplus1-instance-image:
  extends:
    - .qa
    - .ee
    - .parallel
  variables:
    CACHE_NAMESPACE_NAME: "false"
    GITLAB_QA_OPTS: "--enable-feature gitaly_enforce_requests_limits"

# ------------------------------------------
# Elasticsearch compatibility jobs
# ------------------------------------------
integration-elasticsearch-compatibility-version-7:
  extends:
    - .qa
    - .ee
  variables:
    ELASTIC_VERSION: "7.17.0"
    QA_SCENARIO: "Test::Integration::Elasticsearch"

integration-elasticsearch-compatibility-version-8:
  extends:
    - .qa
    - .ee
  variables:
    ELASTIC_VERSION: "8.6.2"
    QA_SCENARIO: "Test::Integration::Elasticsearch"

# ------------------------------------------
# Opensearch compatibility jobs
# ------------------------------------------
integration-opensearch-compatibility-version-1:
  extends:
    - .qa
    - .ee
  variables:
    OPENSEARCH_VERSION: "1.3.3"
    QA_SCENARIO: "Test::Integration::Opensearch"

integration-opensearch-compatibility-version-2:
  extends:
    - .qa
    - .ee
  variables:
    OPENSEARCH_VERSION: "2.0.1"
    QA_SCENARIO: "Test::Integration::Opensearch"

# ------------------------------------------
# Relative url
# ------------------------------------------
relative-url:
  extends:
    - .qa
    - .ee
    - .parallel
  variables:
    QA_SCENARIO: Test::Instance::RelativeUrl

# ==========================================
# Post test stage
# ==========================================
e2e-test-report:
  extends: .rules:report:allure-report

upload-knapsack-report:
  extends:
    - .upload-knapsack-report

export-test-metrics:
  extends:
    - .export-test-metrics

generate-test-session:
  extends:
    - .generate-test-session

notify-slack:
  extends:
    - .notify-slack
